<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
    <span style="width:80px;display:inline-block;">用户昵称：</span>
    <input id="nickName" class="mini-textbox" style="width:155px;" value='<%= result.data[0].nickName%>' />

    <span style="width:80px;display:inline-block;margin-left: 30px">用户密码：</span>
    <input id="password" class="mini-textbox"  style="width:155px;"  value="<%= result.data[0].password%>"/>

    <br /><br />

    <span style="width:80px;display:inline-block;">性别：</span>
    <input id="sex" class="mini-combobox" style="width:155px;" data="Genders" value='<%= result.data[0].sex%>'/>

    <span style="width:80px;display:inline-block;margin-left: 30px">直播权限：</span>
    <input id="live" class="mini-combobox" field="id" style="width:155px;" data="liveOptions" value="<%= result.data[0].live_authority%>"/>

    <br /><br />

    <span style="width:80px;display:inline-block;">登录权限：</span>
    <input id="loginStatus" valueField="id" class="mini-combobox" style="width:155px;" data="loginOptions" value="<%= result.data[0].status%>"/>


    <span style="width:80px;display:inline-block;margin-left: 30px">省：</span>
    <input id="province" class="mini-textbox"  style="width:155px;"  value="<%= result.data[0].province%>"/>

    <br /><br />

    <span style="width:80px;display:inline-block;">市：</span>
    <input id="city" class="mini-textbox"  style="width:155px;"  value="<%= result.data[0].city%>"/>

    <span style="width:80px;display:inline-block;margin-left: 30px">个性签名：</span>
    <textarea id="signature" class="mini-textarea"  value="<%= result.data[0].signature%>" style="width: 155px;margin-top: 20px"></textarea>

    <br /><br />
    <span style="width:80px;display:inline-block;">部落id：</span>
    <input id="uid" class="mini-textbox"  style="width:155px;"  value="<%= result.data[0].uid%>"/>
    <span style="width:80px;display:inline-block;margin-left: 30px">用户等级：</span>
    <input id="type" field="id" valueField="id" class="mini-combobox" style="width:155px;" data="typeOptions" value="<%= result.data[0].type%>"/>

    <br /><br />
    <div style="margin: 0 auto;text-align: center">
        <a class="mini-button " iconCls="icon-ok" onclick="updataUser()">确定</a>
        <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
    </div>
</body>
<script>
    var Genders = [{ id: '男', text: '男' }, { id: '女', text: '女'}];
    var liveOptions = [{ id:1,text:'可以直播'},{id:0,text:'不能直播'}];
    var live = '<%= result.data[0].live_authority%>';
    var loginOptions = [{id:'1',text:'允许登陆'},{id:'0',text:'禁止登陆'}];
    var typeOptions = [{id:0,text:'普通会员'},{id:1,text:'VIP'},{id:2,text:'合伙人'},{id:3,text:'联创'},{id:4,text:'总经理'}];
    var loginStatus = '<%= result.data[0].status%>';
    var objectId = '<%= result.data[0].objectId%>';
    function updataUser() {
        var nickName = mini.get("nickName").getValue();
        var sex = mini.get("sex").getValue();
        var province = mini.get("province").getValue();
        var city = mini.get("city").getValue();
        var liveStatus = mini.get("live").getValue();
        var loginStatus = mini.get("loginStatus").getValue();
        var signature = mini.get("signature").getValue();
        var uid = mini.get("uid").getValue();
        var password = mini.get("password").getValue();
        var type = mini.get("type").getValue();
        console.log(liveStatus);
        if (password == "" || password == undefined || password == null) {
            $.ajax({
                type: "POST",
                url: "/getdata/updataUser",
                data: {
                    objectId: objectId,
                    nickName: nickName,
                    sex: sex,
                    province: province,
                    city: city,
                    live: liveStatus,
                    loginStatus: loginStatus,
                    signature: signature,
                    uid: uid,
                    type:type
                },
                success: function (result) {
                    CloseWindow("save");
                }
            })
        }else{
            $.ajax({
                type: "POST",
                url: "/getdata/updataUser",
                data: {
                    objectId: objectId,
                    nickName: nickName,
                    mobilePhoneNumber: mobilePhoneNumber,
                    sex: sex,
                    province: province,
                    city: city,
                    live: liveStatus,
                    loginStatus: loginStatus,
                    signature: signature,
                    uid: uid,
                    password:password
                },
                success: function (result) {
                    CloseWindow("save");
                }
            })
        }
    }
//    关闭窗口
    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }
    function onOk(e) {
        SaveData();
    }
    function onCancel(e) {
        CloseWindow("cancel");
    }


    $(document).ready(function(){
        $("#live").val(function (live) {
            if (live==liveOptions[1].id){
                return liveOptions[1].text;
            }else{
                return liveOptions[0].text;
            }
        });
        $("#loginStatus").val(function (loginStatus) {
            if (loginStatus==loginOptions[1].id&&loginStatus!=""){
                return loginOptions[1].text;
            }else{
                return loginOptions[0].text;
            }
        });
    });
</script>
</html>